const Joi = require('joi');

/**
 * string()  只能是字符串
 * alphanum() 值只能包含 a-zA-Z0-9 的字符串
 * min(length) 最小长度
 * max(length) 最大长度
 * requires()  值必填
 * pattern(正则表达式)  值必须符合正则表达式的规则 
 */

const name = Joi.string().alphanum().min(1).max(32).required();
const alias = Joi.string().min(1).max(32).required();
const auth = Joi.string().min(1).max(32).required();
// const create_time = Joi.string();
const requiredNum = Joi.number().required();
//  校验 rePassword 值与 password 相同并且必填
const rePassword = Joi.any().valid(Joi.ref('password')).required().label('rePassword');

exports.CreateArticle_schema = {
    body: {
        name,
        alias,
        auth,
        createTime: Joi.number()
    }
};
exports.GetarticleList_schema = {
    body: {
        pageNo: requiredNum,
        pageSize: requiredNum,
    }
};
exports.deleteArticle_schema = {
    body: {
        id: requiredNum,
    }
};
exports.getArticleDetail_schema = {
    body: {
        id: requiredNum,
    }
};